package com.example.selfcontrol.controller;

import com.example.selfcontrol.config.Response;
import com.example.selfcontrol.dto.FollowerInfoDTO;
import com.example.selfcontrol.entity.Follower;
import com.example.selfcontrol.service.FollowerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/follower")
@Api(value = "关注视图")
public class FollowerController {
    @Autowired
    private FollowerService followerService ;

    @GetMapping("/subscribes")
    @ApiOperation("获取关注列表")
    public List<FollowerInfoDTO> getFollowers(int userId , int pageNum, int pageSize) {
        return followerService.getFollowers(userId,pageNum,pageSize) ;
    }

    @GetMapping("/fans")
    @ApiOperation("获取粉丝列表")
    public List<FollowerInfoDTO> getFollowees(int userId , int pageNum, int pageSize) {
        return followerService.getFollowees(userId,pageNum,pageSize) ;
    }

    @GetMapping("/add")
    @ApiOperation("添加关注")
    public Response addFollower(int followeeId, int followerId) {
        return followerService.addFollower(followeeId,followerId) ;
    }

    @GetMapping("/isfollower")
    @ApiOperation("是否关注")
    public boolean isFollower(int followerId, int followeeId) {
        return followerService.isFollower(followeeId,followerId) ;
    }
}
